package com.qianfeng.tulingdemo;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.ListView;

public class MainActivity extends AppCompatActivity implements OnMessageResult {
    private ListView mListView;
    private EditText mEditText;
    private MyAdapter mAdapter;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mEditText = (EditText) findViewById(R.id.et);
        mListView = (ListView) findViewById(R.id.listview);
        mAdapter = new MyAdapter(this);
        mListView.setAdapter(mAdapter);

    }

    public void btnclick(View view) {
        //保存输入的内容
        String message = mEditText.getText() + "";
        //清空文本框
        mEditText.setText("");
        //把自己的内容添加带listview上
        MyText myText = new MyText();
        myText.setInfo(message);
        mAdapter.addItem(myText);
        //你说的内容展示到了页面上
        //机器人说的内容还没有，应该获取
        new JsonAsyncTask(this).execute(message);

    }


    @Override
    public void SendStringData(String message) {
        YourText yourText = new YourText();
        yourText.setInfo(message);
        mAdapter.addItem(yourText);

    }
}
